package com.liming.salesman.persist.openjpa;

import com.liming.core.impl.persistence.GenericOpenJpaDao;
import com.liming.salesman.api.dao.ISalesmanBeanDao;
import com.liming.salesman.api.persistence.ISalesmanBean;
import com.liming.salesman.entities.SalesmanBeanImpl;

import java.util.List;

/**
 * @类描述：销售顾问业务服务类
 * @创建人：sunlf
 * @创建时间：2014-1-16. 下午1:01:59
 * @修改人：sunlf
 * @修改时间：2014-1-16. 下午1:01:59
 * @修改备注：
 */


public class SalesmanBeanDaoOpenjpa extends GenericOpenJpaDao<ISalesmanBean, Long> implements ISalesmanBeanDao {
    private final String className = SalesmanBeanImpl.class.getName();

    /**
     * Constructor that sets the entity to Salesman.class.
     */
    public SalesmanBeanDaoOpenjpa() {
//         super(SalesmanBeanImpl.class);
    }

    @Override
    public List<ISalesmanBean> getSalesmanList() {

        return super.getAll(className);
    }

    @Override
    public ISalesmanBean saveSalesman(ISalesmanBean user) {
        return super.save(user);
    }

    @Override
    public void removeSalesman(Long userId) {
        super.remove(className, userId);
    }

    @Override
    public ISalesmanBean getSalesman(Long userId) {
        return super.get(className, userId);
    }

    public ISalesmanBean getSalesman(String username) {
        ISalesmanBean user = this.findUnique("select u from SalesmanBeanImpl u where u.loginName=?1", username);
        return user;
    }
}
